﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>考生信息</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/Jqbox.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/jquery.dialog.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
    <script src="../Js/jquery.loadmask.min.js" type="text/javascript"></script>
     <script type="text/javascript">
　　         //获得参数的方法
         var request = {
             QueryString: function (val) {
                 var uri = window.location.search;
                 var re = new RegExp("" + val + "=([^&?]*)", "ig");
                 return ((uri.match(re)) ? (uri.match(re)[0].substr(val.length + 1)) : null);
             }
         }

         var examID;
         $(function () {
             //获取参数
             if (request.QueryString("examID") != null) {
                 examID = request.QueryString("examID");
             }
             else {
                 showErrorTip("参数错误！");
                 return;
             }
             //显示gride
             $grid = $("#divGrid").ligerGrid({
                 columns: [
               { display: '序号', align: 'center', width: 40, type: 'int', isSort: false,
                   render: function (item, i) {
                       i = i + 1;
                       return i;
                   }
               },
               { display: '员工姓名', name: 'MemberName', align: 'left', width: 90 },
               { display: '工号', name: 'MemberWorkCode', align: 'left', width: 100 },
               { display: '员工手机', name: 'MemberPhone', align: 'left', width: 100 },
               { display: '所属区域', name: 'MemberAre', align: 'center', width: 80 },
               { display: '员工职务', name: 'MemberRole', align: 'center', width: 100 },
               { display: '所在部门', name: 'MemberDept', align: 'left', width: 120 },
               { display: '考试类型', name: 'ModelType', align: 'center', width: 120,
                    render: function (item) {
                        if (item.ModelType == 0)
                            return "随机抽题";
                        else if (item.ModelType == 1)
                            return "手工选题";
                    }
                },
                { display: '考试用时', name: 'C_Time', align: 'center', width: 80 },
                { display: '成绩', name: 'C_Score', align: 'center', width: 80 },
                { display: '状态', name: 'C_Status', align: 'center', width: 70,
                    render: function (item) {

                        if (item.C_Status == "-1")
                            return "<a href='#' onclick='CalcScore(" + item.C_ID + ",&quot;" + item.has_QA + "&quot;);'>【评分】</a>";
                        else if (item.C_Status == "-2")
                            return "【未参考】"
                        else if (item.C_Status == "0")
                            return "<a href='#' onclick='Score_QA(" + item.C_ID + ",&quot;" + item.has_QA + "&quot;);'>【阅卷】</a>";
                        else if (item.C_Status == "1")
                            return "【不合格】";
                        else if (item.C_Status == "2")
                            return "【合格】";
                    }
                },
                { display: '操作', name: 'C_Status', align: 'center', width: 120,
                    render: function (item) {
                        var result = "";
                        var status = parseInt(item.C_Status);

                        if (status > 0) {
                            result += "<a href=\"TestView.htm?kc=" + item.C_ID + "&exid=" + item.ExamID + "\" target=\"_blank\">查看</a>&nbsp;&nbsp;";
                            result += "<a   onclick='ExportWord(" + item.C_ID + ",&quot;" + item.ExamID + "&quot;,&quot;" + item.MemberName + "&quot;)' href='javascript:' >导出</a>&nbsp;&nbsp;";
                        }

                        if (status != -2) {
                            result += "<a href='#' onclick='reexam(" + item.C_ID + ")'>重考</a>";
                        }
                        return result;
                    }
                }],
                 parms: [{ name: 'ExamID', value: examID}],
                 dataAction: 'server', pageSize: 50,
                 url: '../WebServer/ExamRoom.ashx?Action=CandidateList&rnd=' + Math.random().toString(),
                 width: '99%', height: '95%',
                 onDblClickRow: function (data, rowindex, rowobj) {

                 }
             });
         });

         function loadGrid() {
             if (!$grid) return;
             $grid.setOptions({ parms: [{ name: 'ExamID', value: examID}], newPage: 1, Rows: [], Total: 0});   //设置数据参数
             $grid.loadData(true); //加载数据
         }

         //评分
         function CalcScore(id, has_QA) {
             //alert(has_QA);
             //首先评分
             $("#divContent").mask("数据处理中，请稍候......");
             var params = { C_ID: id, rnd: Math.random() };
             $.getJSON("../WebServer/ExamRoom.ashx?Action=CalcScore", params, function (msg) {
                 $("#divContent").unmask();
                 if (msg == null) {
                     showErrorTip("评分失败，请重试！");
                     return;
                 }
                 if (msg.IsSuccess == 1) {
                     showAlertOk("评分成功");
                     $grid.loadData(true); //加载数据
                 }
             });
             //如果是含有问答题，则同时阅卷
             Score_QA(id, has_QA);
         }

         //阅卷
         var C_ID = 0;
         function Score_QA(id, has_QA) {
             if (has_QA=="True") {
                 C_ID = id;
                 ShowDialog("ExamMng/ScoreQA.htm", "编辑", 900, 550);
             }
         }
         //
         var cName = "";
         function ExportWord(cid, exid, mname) { 
           //试卷
             var url = "TestView.htm?kc=" + cid + "&exid=" + exid + "&exprot=11";
             cName = mname+"试卷";
             $("#frmTestView").attr("src", url);

         }
         function Export(fname, _rooturl) {
             var _eurl = "../WebServer/ExportWordHandler.ashx?PageAddress=" + _rooturl + "Temp/" + fname + ".html?time=" + new Date().getTime() + "&Pname=" + encodeURI(cName) + ".doc" + "&Type=doc";
//             ExportLink.href = _eurl;
//             ExportLink.click();
             //页面导出
             window.open(_eurl, "_self");
         }

         function reexam(cid) {
             jqConfirm("该操作将重置该考生的考试记录,该次考试记录作废.确定需要重置考试记录吗?", "重置考试",
                function (action) {
                    if (action == "ok") {
                        $("body").mask("数据处理中，请稍候......");
                        $.post('../WebServer/ExamRoom.ashx?Action=ReExamRoom', { candidateid: cid }, function (data) {
                            $("body").unmask();
                            var rdata = eval("(" + data + ")");
                            if (rdata.IsSuccess > 0) {
                                showAlertOk("修改成功.");
                                loadGrid();
                            } else {
                                showErrorTip("考试资料修改失败.");
                            }
                        });
                        // if end
                    }
                }
             );
         }

     </script>
</head>
<body>
    <div id="divContent">
    <div id="divGrid">
    </div>
    </div>
    <iframe id="frmTestView" height="0px" width="0px" style="display:none"></iframe>
    <a id="ExportLink" href="" target="_blank"></a>
</body>
</html>
